#!/bin/bash

make="${MAKE:-make}"

makesample=false
if [[ $1 == "--sample" ]]
then
	makesample=true
	shift
fi
if [[ $1 == "--nosample" ]]
then
	makesample=false
	shift
fi

cd tools
$make $1 $2 || exit
cd ..

cd lib
$make $1 $2 || exit

cd usb
$make $1 $2 || exit

cd gadget
$make $1 $2 || exit
cd ..

cd ..

cd input
$make $1 $2 || exit
cd ..

cd fs
$make $1 $2 || exit

cd fat
$make $1 $2 || exit
cd ..

cd ..

cd sched
$make $1 $2 || exit
cd ..

cd net
$make $1 $2 || exit
cd ..

cd sound
$make $1 $2 || exit
cd ..

cd ..

if [[ $makesample == true ]]
then
	cd sample
	./makelatest $1 $2 || exit
	cd ..
fi
